Skip to content

Add draw_tree visuals to tutorials 2&3#661

Merged
edwardchalstrey1 merged 37 commits intomasterfrom
add-drawtree-to-tutorials
Dec 11, 2025
Merged

Add draw_tree visuals to tutorials 2&3#661
edwardchalstrey1 merged 37 commits intomasterfrom
add-drawtree-to-tutorials

Conversation

@edwardchalstrey1
Copy link
Copy Markdown
Member

@edwardchalstrey1 edwardchalstrey1 commented Dec 3, 2025

Adds draw_tree visuals using the gambit layout to intro tutorials:

Closes #552

Also includes changes from #668

@review-notebook-app
Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@edwardchalstrey1
Copy link
Copy Markdown
Member Author

edwardchalstrey1 commented Dec 3, 2025

TODO:

  • Windows GH action in python.yml now fails tests because draw_tree not installed. May be best to split doc/requirements.txt to not have openspiel for Windows
  • More stringent checks on gambit repo vs draw_tree don't like how I've not added a type hint for the game arg for draw_tree.draw_tree, so this needs to be updated
  • Python 3.9 cannot install jupyter-tikz since this requires at least 3.10 - notebook tests are already being skipped for 3.9, but need to avoid installing draw_tree for this action too Edit: I have switched 3.9 for 3.10

@edwardchalstrey1
Copy link
Copy Markdown
Member Author

@tturocy @rahulsavani Though I'm still fixing a couple of GH actions issues (see comment above), the actual tutorial updates are ready for review - see the "ReviewNB" button in the 2nd comment from top

@edwardchalstrey1 edwardchalstrey1 changed the title Add draw_tree visuals to tutorials 2&3 Add draw_tree visuals to tutorials 2&3 and ensure tutorial tests only run when required Dec 4, 2025
@edwardchalstrey1 edwardchalstrey1 marked this pull request as ready for review December 4, 2025 11:46
@@ -24,7 +24,9 @@
"- If the Seller chooses **Honor**, both players receive payoffs of `1`;\n",
Copy link
Copy Markdown
Member

@rahulsavani rahulsavani Dec 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is an extra erroneous "bullet".


Reply via ReviewNB

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The intent here was to illustrate "the game is a root node, with no children" - it's not really necessary I could just remove this or revert to doing len(g.root.children)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha, silly me, fine to keep it though if it could appear a bit to the right that would be better, but not problem if not.

@@ -24,7 +24,9 @@
"- If the Seller chooses **Honor**, both players receive payoffs of `1`;\n",
Copy link
Copy Markdown
Member

@rahulsavani rahulsavani Dec 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The edges for "Not" and "Trust" are very long and it looks a bit weird. Is that easy to change? I would imagine that this game would look fine if the angle of between the edges and the edge lengths at the root were the same or roughly the same as at the seller's node.


Reply via ReviewNB

@@ -24,7 +24,9 @@
"- If the Seller chooses **Honor**, both players receive payoffs of `1`;\n",
Copy link
Copy Markdown
Member

@rahulsavani rahulsavani Dec 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The four code blocks in this section have the code commented out. I guess that's unintentional?


Reply via ReviewNB

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is intentional, I think getting the docs build to save and load files was a bit fiddly and someone running the code locally can run these by just un-commenting, what do you think? It could be possible

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change looks good.

@@ -30,7 +30,11 @@
" - If he chooses to Call, he adds another $1 to the pot.\n",
Copy link
Copy Markdown
Member

@rahulsavani rahulsavani Dec 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue with the length of these edges as with the "one shot trust game".


Reply via ReviewNB

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I'll have a bit of a further fiddle with the default level spacing determining function in draw_tree (how it calculates based off the Gambit layout), though to note, the settings for this in draw_tree will ultimately be customisable parameters

Copy link
Copy Markdown
Member

@rahulsavani rahulsavani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

drawtree is such a great addition. Just a couple of minor comments in those two notebooks (one common to both: can we make the edges at the root node less long).

Fortest_tutorials.py, one minor comment:

  • If I do pytest --run-tutorials, all tests are run, not just for the tutorials; but
  • If I do pytest tests/test_tutorials.py, the tutorials tests are skipped.

If it is easy to have a "run only tutorials" option that could be useful.

@edwardchalstrey1
Copy link
Copy Markdown
Member Author

edwardchalstrey1 commented Dec 4, 2025

TODO:

  • The action label for "Not trust" is not displaying correctly, this was fixed in draw_tree (on main branch) so not sure why this still comes out wrong here
  • Adjust edge lengths as per Rahul's comment above

@edwardchalstrey1 edwardchalstrey1 changed the title Add draw_tree visuals to tutorials 2&3 and ensure tutorial tests only run when required Add draw_tree visuals to tutorials 2&3 Dec 4, 2025
@edwardchalstrey1 edwardchalstrey1 marked this pull request as ready for review December 8, 2025 10:43
@edwardchalstrey1
Copy link
Copy Markdown
Member Author

Sorry @rahulsavani I just clicked re-review but the latest draw_tree changes are still not showing up here, will comment again when fixed

@edwardchalstrey1
Copy link
Copy Markdown
Member Author

edwardchalstrey1 commented Dec 8, 2025

Sorry @rahulsavani I just clicked re-review but the latest draw_tree changes are still not showing up here, will comment again when fixed

@rahulsavani Ok looks good now!

Copy link
Copy Markdown
Member

Looks good to me!

Copy link
Copy Markdown
Member

@rahulsavani rahulsavani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@edwardchalstrey1 edwardchalstrey1 merged commit 995110d into master Dec 11, 2025
28 checks passed
@github-project-automation github-project-automation bot moved this from In review to Done in Ed Chalstrey Gambit priorities Dec 11, 2025
@edwardchalstrey1 edwardchalstrey1 deleted the add-drawtree-to-tutorials branch December 11, 2025 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add easy way to visualise game trees in PyGambit

2 participants